<template>
  <div class="store">
    <headerbar>></headerbar>
    <div class="bottom">
      
      <div class="store-content" v-for="(item,index) in result">
        <div class="content-left" @click="storeturn(item.goodsid)">
          <img :src="item.goodcover" alt="" />
          <span>{{ item.goodsname }}</span>
        </div>
        <div class="content-right" @click='deleteStore(item.storeid)'>
            <span>删除</span>
        </div>
      </div>
         <page-bottom></page-bottom>
    </div>
 
  </div>
</template>
<style lang="scss" scoped>
.store {
//  box-sizing: border-box;
  margin-top: 50px; 
  // padding: 10px; 
}
.store-content {
    // box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    margin-top: 10px;
    padding: 10px;
    .content-right{
          span{
              display: block;
              width: 60px;
              height: 30px;
              line-height: 30px;
              border-radius: 30px;
              color: #fafafa;
              background-color: #ccc;
              font-size: 10px;
              font-weight: 800;
          }
    }
  .content-left {
      display: flex;
      flex-direction: column;
      align-items: center;
      box-sizing: border-box;
      span{
          font-size: 8px;
      }
    img {
      width: 100px;
      height: 100px;
      border-radius: 4px;
    }
  }
}
</style>
<script>
import "../http/request";
import pageBottom from "../components/pagebottom";
import headerbar from "../components/herder.vue";
import { storeAllFunc } from "../http/store";
export default {
  components: {
    pageBottom,
    headerbar,
  },
  data() {
    return {
      result: {},
      uid: "",
    };
  },
  methods:{
    storeturn(goodsid){
      localStorage.setItem('goodsid',goodsid)
      this.$router.push('/productdetail')
    },
      deleteStore(sid){
         storeAllFunc('/store/delete',{storeid:sid}).then(data=>{
            
             console.log('删除返回的数据',data);
             this.result=data
         })
      }
  },
  created() {
    // 设置底部导航栏高亮
    this.uid = localStorage.getItem("userid");
    this.$store.commit("setactive", 2);
    storeAllFunc("/store/all", { uid: this.uid }).then((data) => {
      this.result = data;
    //   console.log(123, this.result);
    });
  },
};
</script>
